home *** CD-ROM | disk | FTP | other *** search
- /*
- ** patch.library
- **
- ** Copyright © 1993-1997 by Stefan Fuchs
- ** Freely distributable.
- */
-
- #ifndef _PATCH_INCLUDES_H
- #include "patch_includes.h"
- #endif
-
-
- /****** patch.library/PatchAlloc ***************************************
- *
- * NAME
- * PatchAlloc -- Allocate and initialize structures (V5)
- *
- * SYNOPSIS
- * structure = PatchAlloc(type)
- * D0
- *
- * APTR PatchAlloc(ULONG type);
- *
- * FUNCTION
- * Allocate and initialize structures for use with patch.library.
- *
- * NOTE
- * Call PatchFreeVec() to free the memory unless documented otherwise.
- *
- * INPUTS
- * type = type of structure to allocate
- *
- * Currently defined types:
- * PS_TYPE_XRESULT - Allocate a PatchXResult structure used
- * in conjunction with the Extended-Result-System
- * (See Example below)
- *
- * RESULT
- * structure = pointer to a structure or NULL on failure
- *
- * EXAMPLE
- * To add 30 ticks to the each dos.library/Delay() function
- * your patchcode would look like this (in SAS/C):
- *
- * __asm __saveds struct PatchXResult *MyDelay(register __d1 ULONG ticks)
- * {
- * struct PatchXResult *xresult;
- * ticks += 30;
- * xresult = (struct PatchXResult *)PatchAlloc(PS_TYPE_XRESULT);
- * if(xresult )
- * {
- * xresult->pxr_RegD1 = ticks;
- * xresult->pxr_RegPattern = PATREG_D1;
- * }
- * return(xresult);
- * }
- *
- *
- * SEE ALSO
- * GetPatch(), PatchFreeVec(), patch.h
- *
- ******************************************************************************
- *
- */
-
- APTR LIBFUNC PatchAlloc( REGD0 ULONG structtype GNUC_REGD0)
- {
- struct PatchXResult *patchxresult;
- switch(structtype)
- {
- case PS_TYPE_XRESULT:
- patchxresult = AAllocmem(sizeof(struct PatchXResult), MEMF_CLEAR| MEMF_PUBLIC, NULL);
- if(patchxresult)
- {
- patchxresult->pxr_Node.ln_Type = PS_TYPE_XRESULT;
- return(patchxresult);
- }
- break;
- }
- return(NULL);
- }